/*This file is part of jasmo.

jasmo is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

jasmo is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with jasmo.  If not, see <http://www.gnu.org/licenses/>.*/

package com.lab9.jasmo.domain;

import java.util.Date;
import java.util.List;

/**
 * a serviced monitor will be observed and tested if working.
 * @author dpsenner@gmail.com
 *
 */
public interface IMonitoredService {
	
	/**
	 * this method retrieves monitored service status.
	 * @return
	 */
	public ServiceState State();
	
	/**
	 * retrieves the message stored along with the last probe. This message
	 * can also be empty or null.
	 * @return
	 */
	public String Message();
	
	/**
	 * this method implements the probing functionality that a subclass needs to implement
	 * and the monitoring framework will call to probe the functionality of a service.
	 */
	public ProbeResult Probe();
	
	/**
	 * this method returns the date when the last probe was done. In case
	 * the service state is still untested, it should always return the
	 * current time.
	 * @return
	 */
	public Date LastProbe();
	
	/**
	 * updates the state of this monitored service.
	 * @param state
	 * @param when
	 * @param string
	 */
	public void UpdateState(ServiceState state, Date when, String string);
	
	/**
	 * retrieves all services that depend upon this service to be up
	 * and running. if this service fails, the child services cannot
	 * work properly too.
	 * @return
	 */
	public List<IMonitoredService> DependingServices();
	
	/**
	 * a list of actions that should be done when a service state changes.
	 * @return
	 */
	public List<IAction> Actions();

	/**
	 * marks how often this service should be probed, the timeout is specified in milliseconds.
	 * @return
	 */
	public long ProbeTimeout();
}
